package com.ruoyi.web.controller.ora;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ora.domain.CustomModel;
import com.ruoyi.ora.service.ICustomModelService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 模式配置Controller
 * 
 * @author liuwp
 * @date 2025-03-19
 */
@RestController
@RequestMapping("/ora/custom_model")
public class CustomModelController extends BaseController
{
    @Autowired
    private ICustomModelService customModelService;

    /**
     * 查询模式配置列表
     */
    @PreAuthorize("@ss.hasPermi('ora:custom_model:list')")
    @GetMapping("/list")
    public TableDataInfo list(CustomModel customModel)
    {
        startPage();
        List<CustomModel> list = customModelService.selectCustomModelList(customModel);
        return getDataTable(list);
    }

    /**
     * 导出模式配置列表
     */
    @PreAuthorize("@ss.hasPermi('ora:custom_model:export')")
    @Log(title = "模式配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CustomModel customModel)
    {
        List<CustomModel> list = customModelService.selectCustomModelList(customModel);
        ExcelUtil<CustomModel> util = new ExcelUtil<CustomModel>(CustomModel.class);
        util.exportExcel(response, list, "模式配置数据");
    }

    /**
     * 获取模式配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('ora:custom_model:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(customModelService.selectCustomModelById(id));
    }

    /**
     * 新增模式配置
     */
    @PreAuthorize("@ss.hasPermi('ora:custom_model:add')")
    @Log(title = "模式配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CustomModel customModel)
    {
        return toAjax(customModelService.insertCustomModel(customModel));
    }

    /**
     * 修改模式配置
     */
    @PreAuthorize("@ss.hasPermi('ora:custom_model:edit')")
    @Log(title = "模式配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CustomModel customModel)
    {
        return toAjax(customModelService.updateCustomModel(customModel));
    }

    /**
     * 删除模式配置
     */
    @PreAuthorize("@ss.hasPermi('ora:custom_model:remove')")
    @Log(title = "模式配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(customModelService.deleteCustomModelByIds(ids));
    }
}
